import request from '@/utils/request'
import { getMchId } from '@/utils/token-util'

const PREFIX = '/common'
/**
 * 单位列表
 */
export function listUnit() {
  return request.get(`${PREFIX}/unit`)
}

/**
 * 货主列表
 */
export function listSupplier() {
  return request.get(`${PREFIX}/supplierList`)
}

/**
 * 仓库列表
 */
export function listWarehouse(params = {}) {
  return request.get(`${PREFIX}/warehouseList`, { params })
}

/**
 * 已绑定仓库列表
 */
export function ListToWarehouse(params = {}) {
  return request.get(`${PREFIX}/userToWList`, { params })
}

/**
 * 货主绑定的仓库列表
 */
export function listBanWarehouse(supplier_id) {
  return request.get(`${PREFIX}/banWarehouseList`, { params: { supplier_id } })
}

/**
 * 商品列表
 */
export function listProduct(params) {
  return request.get(`${PREFIX}/productList`, { params })
}

/**
 * 库区类型列表
 */
export function listWlType() {
  return request.get(`${PREFIX}/wlType`)
}

/**
 * 采购单据状态
 */
export function listPurchaseStatus() {
  return request.get(`${PREFIX}/purchaseStatus`)
}

/**
 * 采购单据状态
 */
export function listWlList(warehouse_id) {
  const params = { warehouse_id, mch_id: getMchId() }
  return request.get('/common/wlList', { params })
}

/**
 * 货主绑定的仓开放用户列表
 */
export function listSu(supplier_id) {
  return request.get(`${PREFIX}/suList`, { params: { supplier_id } })
}
